package com.cmcc.driver.data.entity

import android.os.Parcel
import android.os.Parcelable

data class OrderTemp(
    val bountyFee: Double,
    val createTime: String?,
    val driverId: String?,
    val durationFee: Double,
    val endAddress: String?,
    val endCoordinates: Coordinate?,
    val id: String?,
    val mileageFee: Double,
    val passengerId: String?,
    val remark: String?,
    val startAddress: String?,
    val startCoordinates: Coordinate?,
    val status: Int,
    val totalAmount: Double,
    val tunnel: Tunnel?,
    val tunnelName:String?,
    val tunnelCode:String?,
    val vehicleTypeName:String?,
    val vehicleTypeCode:String?,
    val stationIndex:String?,
    val type:Int,
    val startTime:String?
) : Parcelable {
    constructor(parcel: Parcel) : this(
        parcel.readDouble(),
        parcel.readString(),
        parcel.readString(),
        parcel.readDouble(),
        parcel.readString(),
        parcel.readParcelable(Coordinate::class.java.classLoader),
        parcel.readString(),
        parcel.readDouble(),
        parcel.readString(),
        parcel.readString(),
        parcel.readString(),
        parcel.readParcelable(Coordinate::class.java.classLoader),
        parcel.readInt(),
        parcel.readDouble(),
        parcel.readParcelable(Tunnel::class.java.classLoader),
        parcel.readString(),
        parcel.readString(),
        parcel.readString(),
        parcel.readString(),
        parcel.readString(),
        parcel.readInt(),
        parcel.readString()
    )

    override fun writeToParcel(parcel: Parcel, flags: Int) {
        parcel.writeDouble(bountyFee)
        parcel.writeString(createTime)
        parcel.writeString(driverId)
        parcel.writeDouble(durationFee)
        parcel.writeString(endAddress)
        parcel.writeParcelable(endCoordinates, flags)
        parcel.writeString(id)
        parcel.writeDouble(mileageFee)
        parcel.writeString(passengerId)
        parcel.writeString(remark)
        parcel.writeString(startAddress)
        parcel.writeParcelable(startCoordinates, flags)
        parcel.writeInt(status)
        parcel.writeDouble(totalAmount)
        parcel.writeParcelable(tunnel, flags)
        parcel.writeString(tunnelName)
        parcel.writeString(tunnelCode)
        parcel.writeString(vehicleTypeName)
        parcel.writeString(tunnelCode)
        parcel.writeString(stationIndex)
        parcel.writeInt(type)
        parcel.writeString(startTime)
    }

    override fun describeContents(): Int {
        return 0
    }

    companion object CREATOR : Parcelable.Creator<OrderTemp> {
        override fun createFromParcel(parcel: Parcel): OrderTemp {
            return OrderTemp(parcel)
        }

        override fun newArray(size: Int): Array<OrderTemp?> {
            return arrayOfNulls(size)
        }
    }
}

data class Coordinate(
    val x: Double,//lng
    val y: Double//lat
) : Parcelable {
    constructor(parcel: Parcel) : this(
        parcel.readDouble(),
        parcel.readDouble()
    ) {
    }

    override fun writeToParcel(parcel: Parcel, flags: Int) {
        parcel.writeDouble(x)
        parcel.writeDouble(y)
    }

    override fun describeContents(): Int {
        return 0
    }

    companion object CREATOR : Parcelable.Creator<Coordinates> {
        override fun createFromParcel(parcel: Parcel): Coordinates {
            return Coordinates(parcel)
        }

        override fun newArray(size: Int): Array<Coordinates?> {
            return arrayOfNulls(size)
        }
    }
}